{extend name="public/base"}

{block name="title"}
申请售后
{/block}

{block name="style"}
{css href="/static/wechat/css/refund.css" /}
{/block}

{block name="body"}
<div class="pageControl orderDetails">
    <div class="msui_nav msui_navTop" style="border-bottom: 1px solid #cccccc;">
        <a class="msui_navTop-back" href="javascript:history.back();"><i class="micon-back"></i></a>
        <h1 class="msui_navTop-title">{eq name="data.audit_type" value="1"}退款详情{else /}售后详情{/eq}</h1>
    </div>
    <div class="weui-panel weui-panel_access">
        <div class="weui-panel__bd">
            <span class="weui-media-box weui-media-box_appmsg span_solid">
                <img class="weui-media-box__thumb jujue_img" src="/static/wechat/images/jujuetuikuan_03.png">
              <div class="weui-media-box__bd">
                  <p class="weui-media-box__desc fs08" style="padding: 0px 15px;">{$data.status|get_order_austin_status=###, $data.audit_type}</p>
              </div>
            </span>
            <div class="weui-media-box__bd">
                {switch name="data.status"}
                    {case value="0"}
                    <p class="weui-media-box__desc fs065 fs065color"style="padding: 20px 15px;">用户已申请退款，若您未在72小时内处理，系统将会自动退给用户</p>
                    {/case}
                    {case value="1"}
                    <p class="weui-media-box__desc fs065 fs065color"style="padding: 20px 15px;">退款申请完成，款项预计在1-3个工作日到账</p>
                    {/case}
                    {case value="3"}
                    <p class="weui-media-box__desc fs065 fs065color"style="padding: 20px 15px;">退款申请已经取消</p>
                    {/case}
                    {case value="4"}
                    <p class="weui-media-box__desc fs065 fs065color"style="padding: 20px 15px;">退款申请申诉中...</p>
                    {/case}
                    {case value="5"}
                    <p class="weui-media-box__desc fs065 fs065color"style="padding: 20px 15px;">退款申请已经关闭</p>
                    {/case}
                    {case value="2"}
                    <p class="weui-media-box__desc fs065 fs065color"style="padding-top: 15px;">您拒绝了退款申请，拒绝原因:{$data.merchant_msg}</p>
                    {/case}

                {/switch}
            </div>
        </div>
    </div>

    <!--退款详情-->
    <div class="tuikuandiv">
        <p>退款金额：<span>￥{$data.return_money}</span></p>
        <!--<p>退款单号：<span>135416587135130534135613151</span></p>-->
        <p>申请时间：<span>{$data.add_time|date='Y-m-d H:i:s', ###}</span></p>
        <p>退款原因：<span>{$data.cause}</span></p>
        <p><span class="wentims">问题描述：</span><span class="miaoshu">{$data.msg}</span></p>


        <!--用户退款附带的图片-->

        <div class="yhimg">
            {notempty name="data.img3"}
            <div>
                <img src="{$data.img3}" />
            </div>
            {/notempty}
            {notempty name="data.img2"}
            <div>
                <img src="{$data.img2}" />
            </div>
            {/notempty}
            {notempty name="data.img1"}
            <div>
                <img src="{$data.img1}" />
            </div>
            {/notempty}
        </div>
    </div>

    <!--查看完整协商记录-->
    <!--<a class="axieyi">查看完整协商记录<i class="wzright"></i></a>-->

    <!--底部-->
    <div class="fixbotm" style="display:none;width:100%;background:#FC4208;">
        <a href="javascript:;" id="s_queding_but" data-id="{$data.id}" style="background-color:#6EB63B;color:#FFFFFF;width:49%;">同意</a>
        <a href="javascript:;" id="s_jujue_but" data-id="{$data.id}" style="background-color:#FC4208;color:#FFFFFF;width:49%;float:right;">拒绝</a>
    </div>
</div>
<div id="loadingToast" style="display:none;">
    <div class="weui-mask_transparent"></div>
    <div class="weui-toast">
        <i class="weui-loading weui-icon_toast"></i>
        <p class="weui-toast__content">数据加载中</p>
    </div>
</div>
{/block}

{block name="javascript"}
{js href="/static/wechat/js/refund.js" /}

<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
    wx.config({
        //debug: true,
        appId: '{$signPackage.appId}',
        timestamp: parseInt('{$signPackage.timestamp}'),
        nonceStr: '{$signPackage.nonceStr}',
        signature: '{$signPackage.signature}',
        jsApiList: [
            // 所有要调用的 API 都要加到这个列表中
            'previewImage'
        ]
    });
    //调微信原生查看图片
    $('.yhimg img').click(function(){
        var tmpArr = new Array();
        for(i=0;i<$('.yhimg img').length;i++){
            tmpArr[i] = $('.yhimg img')[i].src;
        }
        try{
            wx.previewImage({current:$(this)[0].src,urls:tmpArr});
        }catch(e){alert('需要在微信中查看');}
    });
</script>

<script>
    $(function () {
        var data_status = parseInt('{$data.status}');
        if( data_status==0 ){
            $('.fixbotm').show();
        }
        $("#s_queding_but").click(function () {
            if (!confirm('确定退款？')) {
                return false;
            }
            var _this = $(this);
            $.get('{:url("austin_repair_tongyi")}', {id : _this.data('id')}, function (msg) {
                if (msg.code == 200) {
                    alert("同意退款成功");
                    window.location.reload();
                } else {
                    var code = msg.code;
                    $.alert(error_code[code]);
                }
            });
        });
        $("#s_jujue_but").click(function () {
            var _this = $(this);
            $.prompt({
                title: '确定拒绝退款?',
                text: '请输入拒绝退款原因:',
                input: '',
                empty: false, // 是否允许为空
                onOK: function (input) {

                    $.get('{:url("austin_repair_jujue")}', {id : _this.data('id'),merchant_msg : input}, function (msg) {
                        if (msg.code == 200) {
                            alert("拒绝退款成功");
                            window.location.reload();
                        } else {
                            var code = msg.code;
                            $.alert(error_code[code]);
                        }
                    });

                },
                onCancel: function () {
                    return false;
                }
            });

        });
    });

</script>
{/block}